﻿import { Layout, Menu, Icon, PageHeader, Button } from 'antd';
import React from 'react';
import 'antd/dist/antd.css';
import './css/Home.css';
import TeacherInfo from '../components/TeacherInfo.js';
import StudentInfo from '../components/StudentInfo.js';
import TeacherEvaluation from '../components/TeacherEvaluation.js'
import HeadmasterEvaluation from '../components/HeadmasterEvaluation.js'
import StudentEvaluation from '../components/StudentEvaluation.js'
import RequiredCourse from '../components/RequiredCourse.js'
// import ElectiveCourse from '../components/ElectiveCourse.js'
import Login from './Login.js'
import Register from './Register.js'
import util from './js/util.js'
import { BrowserRouter, HashRouter, Route, Link } from 'react-router-dom';

const { SubMenu } = Menu;
const { Header, Content, Sider } = Layout;
class Home extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            password: "",
            username: "",
        }
    }
    componentDidMount() {
        var cookie = util.getCookie('loginUsername')
        return cookie
    }
    outLogin() {
        // let username = util.getCookie('loginUsername')
        util.setCookie('loginUsername', '', { path: '/', expires: -1 })
        this.props.history.push('/login')
    }
    render() {
        return (
            <Layout>
                {/* <Header className="header">
                <div>
                <h1 style={{ color: '#fff' }}>课程评价系统</h1>
                    <h2 style={{ color: '#fff' }}>56675</h2>
                       <span >欢迎你，</span>{this.state.username} 
                    <span style={{ color: '#fff',marginRight:20 }} onClick={this.outLogin.bind(this)}>退出</span>
                </div>
                    
                </Header> */}
                <PageHeader className='header' style={{ backgroundColor: '#999', color: '#fff' }}
                    ghost={false}
                    title='课程评价系统'
                    extra={[
                        <Button key="2" style={{ border: 0, color: 'red' }}>欢迎你:{this.componentDidMount()}</Button>,
                        <Button key="1" type="primary" onClick={this.outLogin.bind(this)}>
                            注销
        </Button>,
                    ]}
                ></PageHeader>
                <BrowserRouter>
                    <Layout>
                        <Sider width={200} style={{ backgroundColor: '#999' }}>
                            <Menu
                                mode="inline"
                                defaultSelectedKeys={['1']}
                                defaultOpenKeys={['sub1']}
                                style={{ height: '100%', borderRight: 0 }}
                            >
                                <SubMenu
                                    key="sub1"
                                    title={
                                        <span>
                                            <Icon type="user" />
                                            <Link to='/'>用户管理模块</Link>
                                        </span>
                                    }
                                >
                                    <Menu.Item key="1"><Link to='/teacherinfo'>教师信息管理</Link></Menu.Item>
                                    <Menu.Item key="2"><Link to='/studentinfo'>学生信息管理</Link></Menu.Item>
                                </SubMenu>
                                <SubMenu
                                    key="sub2"
                                    title={
                                        <span>
                                            <Icon type="laptop" />
                                            <Link to='/'>课程评价模块</Link>
                                        </span>
                                    }
                                >
                                    <Menu.Item key="3"><Link to='/teacherevaluation'>任课教师评价</Link></Menu.Item>
                                    <Menu.Item key="4"><Link to='/headmasterevaluation'>班主任评价</Link></Menu.Item>
                                    <Menu.Item key="5"><Link to='/studentevaluation'>学生评价</Link></Menu.Item>
                                </SubMenu>
                                <SubMenu
                                    key="sub3"
                                    title={
                                        <span>
                                            <Icon type="notification" />
                                            <Link to='/'>成绩管理模块</Link>
                                        </span>
                                    }
                                >
                                    <Menu.Item key="6"><Link to='/requiredcourse'>学生成绩信息</Link></Menu.Item>
                                    {/* <Menu.Item key="7"><Link to='/electivecourse'>选修课程</Link></Menu.Item> */}
                                </SubMenu>
                            </Menu>
                        </Sider>
                        <Layout style={{ padding: '0 24px 24px' }}>
                            <Content
                                style={{
                                    background: '#fff',
                                    padding: 24,
                                    margin: 0,
                                    minHeight: 750,
                                }}
                            >
                                <Route path='/' exact render={() => <h1 style={{ fontSize: 24 }}>欢迎来到课程评价系统！</h1>}></Route>
                                <Route path='/teacherinfo' exact component={TeacherInfo}></Route>
                                <Route path='/studentinfo' exact component={StudentInfo}></Route>
                                <Route path='/teacherevaluation' exact component={TeacherEvaluation}></Route>
                                <Route path='/headmasterevaluation' exact component={HeadmasterEvaluation}></Route>
                                <Route path='/studentevaluation' exact component={StudentEvaluation}></Route>
                                <Route path='/requiredcourse' exact component={RequiredCourse}></Route>
                                {/* <Route path='/electivecourse' exact component={ElectiveCourse}></Route> */}
                                <Route path='/login' exact component={Login}></Route>

                            </Content>
                        </Layout>
                    </Layout>
                </BrowserRouter>
            </Layout>
        )
    }

}
export default Home